/**
 * Created with JetBrains PhpStorm.
 * User: shaoshuai
 * Date: 12-7-13
 */
FlyFight.view.airplane.Renderer = {
    createEl: function (airplaneModel) {
        var size = airplaneModel.getSize();
        var width = size.x * FlyFight.view.CELL_WIDTH_HEIGHT + size.x - 1;
        var height = size.y * FlyFight.view.CELL_WIDTH_HEIGHT + size.y - 1;

        var gridHtml = [];
        var className = '';
        gridHtml.push('<div class="ff-airplane" style="width: ' + width + 'px; height: ' + height + 'px;">');
        for (var i = 0; i < size.y; i += 1) {
            var rowHtml = [];
            rowHtml.push('<div class="ff-airplane-row">');
            for (var j = 0; j < size.x; j += 1) {
                if (airplaneModel.getXY(i, j) == 1) {
                    className = 'ff-airplane-cell-normal';
                } else {
                    className = '';
                }
                rowHtml.push('<span class="ff-airplane-cell ' + className + '" data-x="' + j + '" data-y="' + i + '" style="width:' + FlyFight.view.CELL_WIDTH_HEIGHT + 'px; height:' + FlyFight.view.CELL_WIDTH_HEIGHT + 'px;"></span>');
            }
            rowHtml.push('</div>');
            rowHtml = rowHtml.join('');

            gridHtml.push(rowHtml);
        }
        gridHtml.push('</div>');
        return jQuery(gridHtml.join(''));
    }
};

